vb 截取字符串[恳求大家帮忙]

来源:百度知道 编辑:UC知道 时间:2024/05/10 13:05:34
图像名 PID 服务
========================= ====== =============================================
System Idle Process 0 暂缺
System 4 暂缺
smss.exe 580 暂缺
csrss.exe 656 暂缺
winlogon.exe 684 暂缺
services.exe 728 Eventlog, PlugPlay
lsass.exe 740 ProtectedStorage, SamSs
svchost.exe 888(此数字随机) DcomLaunch, TermService
svchost.exe 1012 RpcSs
svchost.exe 1132 AudioSrv, Dhcp, EventSystem,

是只要这一行吗? 还是只要svchost.exe 开头,带个数字的都要?

只要这一行的代码:
新建工程,2个文本框,text1中放你上在这段文本,text2中显示找到的字符串:

Private Sub Command1_Click()
FindStrS = "svchost.exe"
FindStrE = "DcomLaunch,"

i = InStr(Text1, FindStrS)
If i > 0 Then
j = InStr(i + 1, Text1, FindStrE)
If j > 0 Then Text2 = Mid(Text1, i, j - i) & FindStrE
End If
End Sub